<template>
  <div>
    <h1>{{ msg }}</h1>
    <button @click="rev">点我翻转</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: 'ABC'
    }
  },

  methods: {
    rev() {
      /* 1.将msg切割成字符数组
      const arr = this.msg.split('')
      2. 将数组翻转
      console.log(arr)
      reverse 会不会修改原数组?
      会,sort()也会
      arr.reverse()
      console.log(arr)
      3. 将数组拼接成字符串赋值给 msg
      this.msg = arr.join('') */
      this.msg = this.msg.split('').reverse().join('')
    }
  }
}
</script>

<style lang="scss" scoped>

</style>